package app.tools.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

//声明为服务层
@Service
public class RedisTool {
    @Autowired
    private RedisTemplate redisTemplate;
    private static final String FIELD = "person";

    /**
     * 写入缓存
     */

    public synchronized List<Map<String, Object>> setValue(List<Map<String, Object>> list) {
        return null;
    }

    public List<Map<String, Object>> getValue() {
        return null;
    }

    public boolean isExitValue(String k) {
        return redisTemplate.hasKey(k);
    }

    public void setStrValue(String k, Object v) {
        redisTemplate.opsForValue().set(k, v);
    }

    public String getStrValue(String account) {
        return String.valueOf(redisTemplate.opsForValue().get(account));
    }

    public void removeValue(String username) {
        redisTemplate.opsForValue().getOperations().delete(username);
    }
}
